package com.tangding.log.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.tangding.common.utils.JacksonUtil;
import com.tangding.log.LogMatcher;

/**
 * @description 
 *
 * @author Ranger
 * @version 2017年12月20日_下午5:23:55
 *
 */
@Component
public class UpdateGamesSettingsLog extends LogMatcher {
	
    static Map<String, String> gameName2Display = new HashMap<String, String>();
    static {
    	gameName2Display.put("GodDragon", "神龙宝藏");
    	gameName2Display.put("BenzAndBmw", "奔驰宝马");
    	gameName2Display.put("GoldShark", "金鲨银鲨");
    	gameName2Display.put("ForestParty", "森林舞会");
    	gameName2Display.put("Jinchan", "金蟾捕鱼");
    }
    
	@Override
	public String cmdDisplay(String cmd, Object... args) {
		Object[] as = (Object[])(args[0]);
		@SuppressWarnings("unchecked")
		List<Map<String, Object>> list = JacksonUtil.readValue(JacksonUtil.toJson(as[0]), List.class);
		StringBuffer sb = new StringBuffer();
		sb.append("\r\n");
		for (int i = 0; i < list.size(); i++) {
			String gameName = gameName2Display.get(JacksonUtil.get(list.get(i), "gameName", true));
			String values = JacksonUtil.get(list.get(i), "values", true);
			sb.append("【" + gameName +"】进行配置" + values);
			sb.append("\r\n");
		}
		return "对游戏" + sb.toString();
	}
}
